package org.lmj.dim.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.lmj.dim.dto.WhoAmIDTO;
import org.lmj.dim.mapper.UserMapper;
import org.lmj.dim.po.ServerResponse;
import org.lmj.dim.po.UserEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * Created by lmj on 2021/3/15.
 */
@RequestMapping
@RestController
public class WhoAmIController {
    @Autowired
    UserMapper userMapper;

    @RequestMapping("/whoAmI")
    public ServerResponse login(@Valid @RequestBody WhoAmIDTO userDTO) {
        QueryWrapper<UserEntity> objectQueryWrapper = new QueryWrapper<>();
        UserEntity dbUser = userMapper.selectOne(objectQueryWrapper.eq("id", userDTO.getId()));
        return ServerResponse.success(dbUser);
    }
}
